home *** CD-ROM | disk | FTP | other *** search
/ Aminet 32 / Aminet 32 (1999)(Schatztruhe)[!][Aug 1999].iso / Aminet / dev / lang / Python151_Src.lha / Python1.5_Source / Python / hypot.c < prev    next >
C/C++ Source or Header  |  1998-01-14  |  355b  |  29 lines

  1. /* hypot() replacement */
  2.  
  3. #include "config.h"
  4. #include "myproto.h"
  5. #include "mymath.h"
  6.  
  7. double hypot Py_PROTO((double x, double y));
  8.  
  9. double hypot(x, y)
  10.     double x;
  11.     double y;
  12. {
  13.     double yx;
  14.  
  15.     x = fabs(x);
  16.     y = fabs(y);
  17.     if (x < y) {
  18.         double temp = x;
  19.         x = y;
  20.         y = temp;
  21.     }
  22.     if (x == 0.)
  23.         return 0.;
  24.     else {
  25.         yx = y/x;
  26.         return x*sqrt(1.+yx*yx);
  27.     }
  28. }
  29.